#ifndef PHOTOPLUGIN_H
#define PHOTOPLUGIN_H

#include <QLabel>
#include <QObject>
#include <Maestro/mcplugins.h>
#include <phonon/seekslider.h>
#include <QFuture>
#include "imagedisplayer.h"

typedef QList<QImage> ImageList;
typedef QFuture<void> Future;
class PhotoPlugin : public FileSelectionInterface {
    Q_OBJECT
    Q_INTERFACES(MenuItemInterface)
    Q_INTERFACES(FileSelectionInterface)
    Q_ENUMS(TransitionEffect)
public:
    PhotoPlugin();
    enum TransitionEffect { None, Fade };
    QString getName();
    QIcon getImage();
    QIcon getIcon(MediaFile * mediaFile);
    QStringList getExtensions();
    void test();
    QWidget * getInterface();
    void setMediaFile(MediaFile * mediaFile);
    bool isPlaying () { return true;}
    void setMediaQueue(QList<MediaFile *> * files, int start=0);
    bool setSlider(Phonon::SeekSlider * slider);
public slots:
    void play();
    void fastForward();
    void rewind();
    void stop();
    void next();
    void previous();
    void setShuffleState(bool shuffleState);
    void setRepeatState(int repeatState);
    void setVolume(int);
    void continueTransition();

signals:
    void stateChanged(bool playing);
    void error(QString errorMessage);
    void fileChanged(QString name, int index, int total);
private:
    void calculateTransitions(QList<QImage> * transitions, QImage baseImage, TransitionEffect effect);
    QLabel * imageHolder;
    QList<QImage> queue;
    QList<QImage> tmpQueue;
    QList<MediaFile *> *files;
    QList<Future> transitionLoaders;
    QList<ImageList *> transitions;
    int index;
    QTimer * timer;
    QTimer * transitionTimer;
    int transitionTime;
    int fastTime;
    int normalTime;
    int state;
    TransitionEffect effect;
    int transitionCount;
    int repeat;
    bool shuffle;
};

#endif // PHOTOPLUGIN_H
